package com.ruoyi.file_info.service.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.file_info.domain.CompetitionFileInfo;
import com.ruoyi.file_info.mapper.CompetitionFileInfoMapper;
import com.ruoyi.file_info.service.ICompetitionFileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 文件上传Service业务层处理
 * 
 * @author LBH
 * @date 2023-12-14
 */
@Service
public class CompetitionFileInfoServiceImpl implements ICompetitionFileInfoService
{
    @Autowired
    private CompetitionFileInfoMapper competitionFileInfoMapper;

    /**
     * 查询文件上传
     * 
     * @param fileId 文件上传主键
     * @return 文件上传
     */
    @Override
    public CompetitionFileInfo selectCompetitionFileInfoByFileId(String fileId)
    {
        return competitionFileInfoMapper.selectCompetitionFileInfoByFileId(fileId);
    }

    /**
     * 查询文件上传列表
     * 
     * @param competitionFileInfo 文件上传
     * @return 文件上传
     */
    @Override
    public List<CompetitionFileInfo> selectCompetitionFileInfoList(CompetitionFileInfo competitionFileInfo)
    {
        return competitionFileInfoMapper.selectCompetitionFileInfoList(competitionFileInfo);
    }

    /**
     * 新增文件上传
     * 
     * @param competitionFileInfo 文件上传
     * @return 结果
     */
    @Override
    public int insertCompetitionFileInfo(CompetitionFileInfo competitionFileInfo)
    {
        return competitionFileInfoMapper.insertCompetitionFileInfo(competitionFileInfo);
    }
    @Override
    public int insertCompetitionFileInfo(Map map) {
        CompetitionFileInfo competitionFileInfo = new CompetitionFileInfo();
        competitionFileInfo.setFileId(String.valueOf(UUID.randomUUID()));
        competitionFileInfo.setFileName(String.valueOf(map.get("file_name")));
        competitionFileInfo.setFilePath(String.valueOf(map.get("file_path")));
        competitionFileInfo.setCreateby(String.valueOf(map.get("createby")));
        competitionFileInfo.setFileType(String.valueOf(map.get("file_type")));
        competitionFileInfo.setCreatetime(DateUtils.getNowDate());
        return competitionFileInfoMapper.insertCompetitionFileInfo(competitionFileInfo);
    }

    /**
     * 修改文件上传
     * 
     * @param competitionFileInfo 文件上传
     * @return 结果
     */
    @Override
    public int updateCompetitionFileInfo(CompetitionFileInfo competitionFileInfo)
    {
        return competitionFileInfoMapper.updateCompetitionFileInfo(competitionFileInfo);
    }

    /**
     * 批量删除文件上传
     * 
     * @param fileIds 需要删除的文件上传主键
     * @return 结果
     */
    @Override
    public int deleteCompetitionFileInfoByFileIds(String[] fileIds)
    {
        return competitionFileInfoMapper.deleteCompetitionFileInfoByFileIds(fileIds);
    }

    /**
     * 删除文件上传信息
     * 
     * @param fileId 文件上传主键
     * @return 结果
     */
    @Override
    public int deleteCompetitionFileInfoByFileId(String fileId)
    {
        return competitionFileInfoMapper.deleteCompetitionFileInfoByFileId(fileId);
    }
}
